<template>
  <uni-nav-bar title="我的账户" color="#333" left-icon="left" @clickLeft="clickLeft()" statusBar></uni-nav-bar>
  <environment></environment>
  <!-- <Account /> -->
  <view class="flex-col-hcenter">
    <!-- info -->
    <accountTop ref="getAccount" :type="'count'"></accountTop>
    <!-- filter -->
    <view class="list">
      <view v-for="(item, index) in list" :key="index" @click="navTo(item.path)">
        <image :src="item.icon" mode="" :style="{ width: index === 4 ? '50rpx' : '' }"></image>
        <text>{{ item.text }}</text>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
  import { ref, onMounted } from 'vue';
  import { navBack, navTo, redirectTo } from '@/utils/navigator';
  import accountTop from '@c/account/accountTop.vue';
  import environment from '@c/pobulic/environment.vue';
  import { onShow } from '@dcloudio/uni-app';
  import { showLoading } from '@/utils/prompt';
  const type = ref('');
  const getAccount = ref(null);
  const list = [
    { icon: '../../static/index/img1.png', text: '充值', path: 'mine/Recharge' },
    { icon: '../../static/index/img2.png', text: '绑卡', path: 'giftCard/tokenCard' },
    { icon: '../../static/index/img3.png', text: '提现', path: 'account/withdraw' },
    { icon: '../../static/index/img4.png', text: '明细', path: 'account/details' },
    { icon: '../../static/index/img5.png', text: '充值明细', path: 'account/detailed' },
  ];
  onShow(() => {
    showLoading('加载中...');
    setTimeout(() => {
      getAccount.value.getAccountInfo();
    }, 300);
  });
  onMounted(() => {
    type.value = location.href.split('Store=')?'1':''
  })
  function clickLeft() {
    if (type.value == '1') {
      redirectTo('index/mine');
    } else {
      navBack();
    }
  }
</script>
<style scoped lang="less">
  .list {
    width: 96%;
    margin: 15rpx auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    background-color: #fff;
    border-radius: 5px;
    padding: 20rpx 0rpx 0px 0rpx;
    box-sizing: border-box;

    view {
      width: 25%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      margin-bottom: 20rpx;

      image {
        width: 40rpx;
        height: 40rpx;
      }

      text {
        font-size: 20rpx;
        font-weight: 400;
        color: #333333;
        margin-top: 10rpx;
      }
    }
  }
</style>